{include file="public/nheader"}
<div class="layui-fluid layui-bg-white">
    <form action="{:url()}" class="layui-form layui-form-fixed">
        <input type="hidden" value="{$row.id|default='0'}" name="id" />
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>任务名称
            </label>
            <div class="layui-input-block">
                <input type="text" name="title" required="" lay-verify="required" autocomplete="off" class="layui-input"
                    value="{$row.title|default=''}" placeholder="请填写备注名称">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>师傅ID
            </label>
            <div class="layui-input-block">
                <input type="text" name="rider" required="" lay-verify="required" autocomplete="off" class="layui-input"
                    value="{$row.rider|default=''}" placeholder="师傅ID">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>类型
            </label>
            <div class="layui-input-block">
                <select name="agentid">
                    <option value="">请选择代理账号</option>
                    {foreach $agent as $v}
                    <option value="{$v.id}" {if !empty($row.agentid) && $row.agentid==$v.id}selected{/if}>
                        {$v.nickname}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>状态
            </label>
            <div class="layui-input-block">
                <input type="radio" name="status" value="1" title="进行中" {if !empty($row.status) &&
                    $row.status==1}checked{/if}>
                <input type="radio" name="status" value="2" title="结束" {if !empty($row.status) &&
                    $row.status==2}checked{/if}>
            </div>
        </div>
        <div class="layui-form-item" id="provinceshow">
            <label class="layui-form-label">
                <font color="red">* </font>省份
            </label>
            <div class="layui-input-block">
                <select name="province" data-area="" lay-filter="province" lay-search>
                    <option value="">请选择选择省份</option>
                    {foreach $province as $v}
                    <option value="{$v.area_code}" {if !empty($row.province) &&
                        $row.province==$v.area_code}selected{/if}>{$v.name}</option>
                    {/foreach}
                </select>
            </div>
        </div>

        <div class="layui-form-item" id="cityshow">
            <label class="layui-form-label">
                <font color="red">* </font>城市
            </label>
            <div class="layui-input-block">
                <select name="city" data-area="" lay-filter="city" lay-search>
                    <option value="">请选择选择城市</option>
                    {foreach $city as $v}
                    <option value="{$v.area_code}" {if !empty($row.city) && $row.city==$v.area_code}selected{/if}>
                        {$v.name}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item" id="areashow">
            <label class="layui-form-label">
                <font color="red">* </font>区域
            </label>
            <div class="layui-input-block">
                <select name="area" data-area="" lay-filter="area" lay-search>
                    <option value="">请选择选择区域</option>
                    {foreach $area as $v}
                    <option value="{$v.area_code}" {if !empty($row.area) && $row.area==$v.area_code}selected{/if}>
                        {$v.name}</option>
                    {/foreach}
                </select>
            </div>
        </div>

        <div class="layui-form-item" id="streetshow">
            <label class="layui-form-label">
                <font color="red">* </font>街道
            </label>
            <div class="layui-input-block">
                <select name="street" data-area="" lay-filter="street">
                    <option value="">请选择选择街道</option>
                    {foreach $street as $v}
                    <option value="{$v.id}" {if !empty($row.street) && $row.street==$v.id}selected{/if}>
                        {$v.name}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>地址库
            </label>
            <div class="layui-input-block">
                <div class="layui-input-inline" style="width: 50%;">
                    <a class="layui-btn layui-btn-btn layui-btn-xs add" onclick="addtable2()">添加信息</a>
                    <table class="layui-table" id="table2" lay-filter="table2">
                        <thead>
                            <tr>
                                <td>姓名</td>
                                <td>电话</td>
                                <td>车牌号</td>
                                <td>服务地址</td>
                                <td>停靠位置</td>
                            </tr>
                        </thead>
                        <tbody>
                            {if !empty($row.parpam)}
                            {foreach $row.parpam as $k =>$v}
                            <tr>
                                <td>
                                    <input style="width:100px" required="" lay-verify="required" type="text" id="layui-input"
                                        class="layui-input" name="parpam[{$k}][name]" value="{$v.name|default=''}">
                                </td>
                                <td>
                                    <input style="width:150px" required="" lay-verify="required" type="text" id="layui-input"
                                        class="layui-input" name="parpam[{$k}][mobile]" value="{$v.mobile|default=''}">
                                </td>
                                <td>
                                    <input style="width:150px" type="text" id="layui-input"
                                        class="layui-input" name="parpam[{$k}][cards]" value="{$v.cards|default=''}">
                                </td>
                                <td>
                                    <input style="width:150px" required="" lay-verify="required" type="text" id="layui-input"
                                        class="layui-input" name="parpam[{$k}][posaddress]" value="{$v.posaddress|default=''}">
                                </td>
                                <td>
                                    <input style="width:150px" required="" lay-verify="required" type="text" id="layui-input"
                                        class="layui-input" name="parpam[{$k}][address]" value="{$v.address|default=''}">
                                </td>
                            </tr>
                            {/foreach}
                            {/if}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <div class="layui-footer layui-form-item layui-center ">
            <button class="layui-btn" lay-filter="submitIframe" type="button" lay-submit>提交</button>
            <button class="layui-btn layui-btn-primary" type="button" sa-event="closeDialog">取消</button>
        </div>
    </form>
</div>
{include file="public/nfooter"}
<script>
    function addtable2() {
        var i = $('#table2 tbody tr').length;
        //你要添加的html
        var html = '<tr>' +
            '<td><input style="width:100px" required="" lay-verify="required" type="text" id="layui-input" class="layui-input" name="parpam[' + i + '][name]" value=""></td>' +
            '<td><input style="width:150px" required="" lay-verify="required" type="text" id="layui-input" class="layui-input" name="parpam[' + i + '][mobile]" value=""></td>' +
            '<td><input style="width:150px"  type="text" id="layui-input" class="layui-input" name="parpam[' + i + '][cards]" value=""></td>' +
            '<td><input style="width:150px" required="" lay-verify="required" type="text" id="layui-input" class="layui-input" name="parpam[' + i + '][posaddress]" value=""></td>' +
            '<td><input style="width:150px" required="" lay-verify="required" type="text" id="layui-input" class="layui-input" name="parpam[' + i + '][address]" value=""></td>' +
            '</tr>';
        $(html).appendTo($('#table2 tbody:last'));
        layui.use(['form'], function () {
            $ = layui.jquery;
            var form = layui.form;
            form.render();
        });
    };
    $('body').on('click', '.del2', function () {
        $(this).closest('tr').remove();
    });
</script>